#pragma once

#include <QString>
#include <unordered_map>
#include <mutex>

class Element
{
public:
    const QString elementStr;
    const QString tabStr;
};
class ElementPool
{
private:
    ElementPool();
public:
    static uint32_t add(const QString &elementStr, const QString &tabStr);
    static Element at(uint32_t id);
    static void free(uint32_t id);
private:
    uint32_t _add(const QString &elementStr, const QString &tabStr);
    Element _at(uint32_t id);
    void _free(uint32_t id);
private:
    std::mutex locker;
    uint32_t lastIndex = 1;
    std::unordered_map<uint32_t, Element> elements = std::unordered_map<uint32_t, Element>(1024);
private:
    static ElementPool *instance();
    static ElementPool *_instance;
};

